package com.examsage.examsage.controller;

import com.examsage.examsage.model.ExamSession;
import com.examsage.examsage.model.vo.ResponseVO;
import com.examsage.examsage.service.IExamSessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author examsage
 * @since 2025-07-02
 */
@RestController
@RequestMapping("/api/v1/exam-sessions")
public class ExamSessionController {

    @Autowired
    private IExamSessionService examSessionService;

    @PostMapping("/")
    public ResponseVO addExamSession(ExamSession examSession) {
        return examSessionService.addExamSession(examSession);
    }

    @GetMapping("/")
    public ResponseVO getExamSession(int year) {
        return examSessionService.getExamSession(year);
    }

    @GetMapping("/{id}")
    public ResponseVO getExamSessionById(@PathVariable Long id) {
        return examSessionService.getExamSessionById(id);
    }

    @PostMapping("/{id}")
    public ResponseVO updateExamSessionById(@PathVariable Long id, ExamSession examSession) {
        return examSessionService.updateExamSessionById(id, examSession);
    }

    @DeleteMapping("/{id}")
    public ResponseVO deleteExamSession(@PathVariable Long id) {
        return examSessionService.deleteExamSessionById(id);
    }
}
